
#import "Chapter.h"



/////////////////////////////////////////////
//  ImageToDataTransformer implmentation
/////////////////////////////////////////////
@implementation ImageToDataTransformer

/////////////////////////////////////////////
// @Override, class method
+(BOOL)allowsReverseTransformation {
  return YES;
}

/////////////////////////////////////////////
// @Override, class method
+(Class)transformedValueClass {
  return [NSData class];
}

/////////////////////////////////////////////
// @Override, defined by NSValueTransformer abstruct
// Image PNG to data
-(id)transformedValue:(id)value {
  NSData *data = UIImagePNGRepresentation(value);
  return data;
}

/////////////////////////////////////////////
// @Override, defined by NSValueTransformer abstruct
// Data to UI image
-(id)reverseTransformedValue:(id)value {

  UIImage *uiImage = [[UIImage alloc] initWithData:value];
  return [uiImage autorelease];
}

@end




/////////////////////////////////////////////
//  Chapter implementation
/////////////////////////////////////////////
@implementation Chapter

/**
 * Dynamic is the default, if you don't set either * @synthesize or dynamic. 
 * Specifying @dynamic merely means that you take
 * responsibility for properly implementing the property
 * accessors based on the signature of the property declaration.
 */

@dynamic name;
@dynamic image;
@dynamic overview;
@dynamic thumbnailImage;
@dynamic instructions;
@dynamic ingredients;
@dynamic type;
@dynamic prepTime;

@end

